<template>
	<view class="root">
		<view class="cen">
			<br>
			<span style="color:#FFFF">注册</span>
			<br>
			<input v-model="name" class="color" type="text" value="" placeholder="账号" />
			<br>
			<input v-model="password" class="color" type="text" value="" placeholder="密码" password="" />
			<br>
			<input v-model="password1" class="color" type="text" value="" placeholder="再次输入密码" password="" />
			<br>
			
			<view class="row">
				
				<button @click="ok" type="default">注册</button>
			</view>
			

		</view>
		


	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'',
				password:'',
				password1:''

			}
		},
		methods: {
			ok(){
				if(this.name!=''&& this.password!='' && this.password1!=''){
					
					if(this.password==this.password1){
						uni.request({
							url:'http://192.168.1.3:9090/user/register',
							method:'POST',
							data:{
								name:this.name,
								password:this.password
							}
						}).then(res=>{
							
							uni.showToast({
							
								
								title:"注册成功"
							})
							uni.redirectTo({
								url:'/pages/login/login'
							})
						})
					}else{
						uni.showToast({
							icon:'error',
							title:"两次密码必须一样"
						})
					}
				}else{
					uni.showToast({
						icon:'error',
						title:"所有空不行为空"
					})
				}
			}

		}
	}
</script>

<style>
	.root {
		width: 100%;
		height: 100vh;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.cen {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: gray;
		border-radius: 20rpx;
		width: 60%;
		height: 500rpx;
	}
	.color{
		background-color: #FFFF;
	}
	.row{
		display: flex;
		flex-direction: row;
		
	}
</style>